#!/usr/bin/env bash

# exit on first failure
set -e

restore_configs
opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB
exec_test $1 $2 "Build Re-ARM Default Configuration"

restore_configs
opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB
opt_enable VIKI2 SDSUPPORT
exec_test $1 $2 "ReARM EFB VIKI2 and SDSUPPORT"

restore_configs
use_example_configs Mks/Sbase
exec_test $1 $2 "MKS SBASE Example Config"

restore_configs
use_example_configs Azteeg/X5GT
exec_test $1 $2 "Azteeg X5GT Example Config"

restore_configs
opt_set MOTHERBOARD BOARD_MKS_SBASE
opt_set EXTRUDERS 2
opt_enable NUM_SERVOS
opt_set NUM_SERVOS 1
opt_enable SWITCHING_EXTRUDER ULTIMAKERCONTROLLER
exec_test $1 $2 "MKS_SBASE SWITCHING_EXTRUDER"

restore_configs
opt_set MOTHERBOARD BOARD_MKS_SBASE
opt_set EXTRUDERS 2
opt_set TEMP_SENSOR_0 1
opt_set TEMP_SENSOR_1 5
opt_set TEMP_SENSOR_BED 1
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT
opt_enable FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY
opt_enable FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE
opt_enable BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY
opt_enable PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT
opt_enable_adv ADVANCED_PAUSE_FEATURE LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA PARK_HEAD_ON_PAUSE
opt_set GRID_MAX_POINTS_X 16
exec_test $1 $2 "MKS SBASE Many Features"

restore_configs
opt_set MOTHERBOARD BOARD_MKS_SBASE
opt_enable COREYX
opt_set_adv FAN_MIN_PWM 50
opt_set_adv FAN_KICKSTART_TIME 100
opt_set_adv XY_FREQUENCY_LIMIT  15
opt_enable_adv SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER FAN_KICKSTART_TIME
opt_enable_adv ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ADVANCED_OK
opt_enable_adv VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS ACTION_ON_KILL
opt_enable_adv EXTRA_FAN_SPEED FWERETRACT Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS
opt_enable_adv MENU_ADDAUTOSTART SDCARD_SORT_ALPHA
opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER BABYSTEPPING DAC_MOTOR_CURRENT_DEFAULT
opt_enable FILAMENT_LCD_DISPLAY FILAMENT_WIDTH_SENSOR
opt_enable FAN_SOFT_PWM SDSUPPORT
opt_enable USE_XMAX_PLUG
exec_test $1 $2 "MKS SBASE Many less common options"

#clean up
restore_configs
